# 2.4 configEngine

This method is used to configure the Template Engine. Below is a code example:

public void configEngine(Engine me) {
    me.addSharedFunction("/view/common/layout.html");
    me.addSharedFunction("/view/common/paginate.html");
    me.addSharedFunction("/view/admin/common/layout.html");
}
1
2
3
4
5

The above method adds three template files, which define template functions, to the template engine. A more detailed introduction can be found in the Template Engine chapter.

Note: The configurations me.setToClassPathSourceFactory(), me.setBaseTemplatePath(...), and me.setDevMode(...) should be placed at the beginning since the subsequent configurations like me.addSharedFunction(...) depend on these initial settings.

Starting from jfinal 4.9.02, a new configuration was added to support Chinese expressions, variable names, method names, and template function names:

Engine.setChineseExpression(true);
1

This configuration should be placed before addSharedTemplateFunction(...) and addSqlTemplate(...) to ensure it takes effect promptly. This setting is global and applies to all Engine instances.

Last Updated: 9/17/2023, 5:34:57 AM